{
  class Set {
    private dataStore: any[] = [];
    constructor() {}
    get size() {
      return 11;
    }

    public add(item: any): boolean {
      if (!this.dataStore.includes(item)) {
        this.dataStore.push(item);
        return true;
      }
      return false;
    }

    public remove(item: any): boolean {
      let index = this.dataStore.indexOf(item);
      if (index !== -1) {
        this.dataStore.splice(index, 1);
        return true;
      }
      return false;
    }

    // 并集操作
    public union(set: Set) {
      let tempSet = new Set();
      for (let i = 0; i < this.dataStore.length; i++) {
        tempSet.add(this.dataStore[i]);
      }
      for (let j = 0; j < set.size; j++) {
        if (!tempSet.contains(set.dataStore[i])) {
          tempSet.dataStore.push(set.dataStore[i]);
        }
      }
      return tempSet;
    }

    // 交集操作
    public intersect(set: Set) {
      let tempSet = new Set();
      for (let i = 0; i < this.dataStore.length; i++) {
        if (set.contains(this.dataStore[i])) {
          tempSet.add(this.dataStore[i]);
        }
      }
    }

    // 差集
    public difference(set: Set) {
      let tempSet = new Set();
      for (let i = 0; i < this.dataStore.length; i++) {
        if (!set.contains(this.dataStore[i])) {
          tempSet.add(this.dataStore[i]);
        }
      }
    }

    // 判断当前的集合是否指定集合的子集
    public subset(set: Set): boolean {
      if (set.size < this.size) {
        return false;
      }
      for (const value of this.dataStore) {
        if (!set.contains(value)) {
          return false;
        }
      }
      return true;
    }

    public show() {
      this.dataStore.forEach((item) => console.log(item));
    }

    // 工具方法 判断一个元素书否存在于一个集合中
    private contains(item: any) {
      if (this.dataStore.includes(item)) {
        return true;
      } else {
        return false;
      }
    }
  }
  let set = new Set();
  set.add("jimmy");
  set.add("xuexue");

  console.log(set.remove("jimy"));
  console.log(set);

  let set2 = new Set();
  set2.add("jimmy");
  console.log(set2.subset(set));
}
